//
// $Id: AboutDialog.java 8 2007-04-18 13:47:40Z z_hossain $
//
// xChess is a multiplatform graphical chess user interface
// Copyright (C) 2007  MD. Z. Hossain <z_hossain@users.sf.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  
// 02110-1301, USA.
//
// For more information visit http://xchess.sourceforge.net
//

package gui;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;

public class AboutDialog extends JDialog {
	private JLabel titleLabel;
	private JLabel descriptionLabel;
	private JButton OKButton;

	public AboutDialog(JFrame frame) {
		super(frame, true);
		initGUI();
	}
	
	private void initGUI() {
		try {

			GridBagLayout thisLayout = new GridBagLayout();
			getContentPane().setLayout(thisLayout);
			setTitle("About");
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

			titleLabel = new JLabel();
			getContentPane().add(titleLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
			titleLabel.setText("<html><h1>xChess 0.03</h1></html>");
			titleLabel.setIcon(new ImageIcon(getClass().getResource("images/logo32.png")));
			titleLabel.setIconTextGap(10);

			descriptionLabel = new JLabel();
			getContentPane().add(descriptionLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
			descriptionLabel.setText("<html>A multiplatform graphical chess user interface<br />" +
					"Copyright (C) 2007  MD. Z. Hossain<br />" +
					"<a href=\"http://xchess.sourceforge.net\">http://xchess.sourceforge.net</a></html>");

			OKButton = new JButton();
			getContentPane().add(OKButton, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
			OKButton.setText("OK");
			OKButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					AboutDialog.this.dispose();
				}
			});
			getRootPane().setDefaultButton(OKButton);
			
			pack();
			setLocationRelativeTo(getOwner());

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
